﻿#include "GlobalFiles.h"
#include "FITK_Kernel/FITKCore/FITKActionOperator.h"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"

Files* FilesWapper::new_Files()
{
    return new Files;
}
void FilesWapper::delete_Files(Files* F)
{
    if (F) delete F;
}
void FilesWapper::static_Files_ImportInpFile(const QString & fileName, const QString& level)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionImportAsParts");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    QString m = "actionImportAsModel";
    if (level.toLower() == "assembly")
        m = "actionImportAsAssembly";
    else if (level.toLower() == "part")
        m = "actionImportAsParts";
    //读取
    oper->setArgs("FileName", fileName);
    oper->setArgs("Emitter", m);
    oper->execProfession();
}
void FilesWapper::static_Files_ExportInpFile(const QString& fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionexport_inp");
    if (oper == nullptr) return;
    oper->setArgs("FileName", fileName);
    //写出
    oper->execProfession();
}

void FilesWapper::static_Files_ExportCCXInpFile( const QString& fileName)
{
    // 获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionexport_ccxinp");
    if (oper == nullptr) return;
    oper->setArgs("FileName", fileName);
    //写出
    oper->execProfession();
}

void FilesWapper::static_Files_OpenDataBase(const QString& fileName)
{
    // 获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionimport_hdf5");
    if (oper == nullptr) return;
    oper->setArgs("FileName", fileName);
    //写出
    oper->execProfession();
}

void FilesWapper::static_Files_SaveDataBase(const QString& fileName)
{
    // 获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionexport_hdf5");
    if (oper == nullptr) return;
    oper->setArgs("FileName", fileName);
    //写出
    oper->execProfession();
}

void FilesWapper::static_Files_OpenVTKFiles(const QString& fileName)
{
    QStringList sliet = fileName.split(",");
    // 获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionImportVTK");
    if (oper == nullptr) return;
    oper->setArgs("FileNames", fileName);
    //写出
    oper->execProfession();
}

 
